<?php
class Admin_RegisterController extends Zend_Controller_Action
{	
    public function init() {
        if (Zend_Auth::getInstance ( 'admin' )->setStorage ( new Zend_Auth_Storage_Session ( 'admin' ) )->hasIdentity () == false) {
			$this->_helper->getHelper ( 'Redirector' )->gotoUrl ( "admin/login" );
		} 
    }
    public function indexAction()
    {
      $this->view->title = "Contact";	
    	try {
           $model = new Vina_Model_Regiseter();
           $dataList = $model->fetchListToArray('1=1', 'id desc');
           $this->view->data = $dataList;     
                
         }catch(Exception $ex){
            echo "<pre>";
            print_r($ex->getMessage());
        }
    
    }
     public function viewAction()
    {
      $this->view->title = "Contact";	
    	try {
    	   $id                     =  $this->_request->getParam('id',false);
           $model = new Vina_Model_Regiseter;
           $dataList = $model->find($id)->toArray();
           $idClassNews = $dataList['class_name'];
           $modelNews  = new Vina_Model_News();
           $className = $modelNews->find($idClassNews)->title;
           $this->view->className = $className;
           $this->view->data = $dataList;     

         }catch(Exception $ex){
            echo "<pre>";
            print_r($ex->getMessage());
        }
    
    }	
    public function deleteAction() {
     $id                     =  $this->_request->getParam('id',false);
     $model = new Vina_Model_Regiseter();
     $where = "id = $id";
     $model->delete($where);
     $this->_redirect($_SERVER['HTTP_REFERER']);
  }
}
